import {createSlice} from "@reduxjs/toolkit";

export interface SystemState {
    adminLayout: number;
}

const initialState: SystemState = {
    adminLayout: parseInt(window.localStorage.getItem("adminLayout") ?? "1"),
};

export const systemSlice = createSlice({
    name: "system",
    initialState,
    reducers: {
        changeAdminLayout: (state) => {
            state.adminLayout = state.adminLayout == 1 ? 2 : 1
            localStorage.setItem("adminLayout", JSON.stringify(state.adminLayout));
        }
    },
});

export const {changeAdminLayout} = systemSlice.actions;
export default systemSlice.reducer;
